package jpnms.src;

import org.junit.Test;
import sun.awt.image.ImageWatched;

import java.util.*;

/**
 * @author jpnms
 * @version 1.0
 * @description: TODO
 * @date 2023/7/13 10:24
 */

/**
 * collection:Set,Queue,List,Map
 * HashSet,TreeSet,SortedSet
 * PriorityQueue,ArrayDeque,Deque
 * ArrayList,LinkedList,Vector,Stack
 * HashMap,LinkedHashMap,TreeMap
 * <p>
 * Comparable,Comparator : 对象排序接口
 * Collections : 容器工具类
 */
public class JavaCollections {
    @Test
    public void test() {
        ArrayList<Integer> arrayList = new ArrayList<>();
        LinkedList<Integer> linkedList = new LinkedList<>();
        Vector<String> vector = new Vector<>();

        HashSet<String> hashSet = new HashSet<>();
        TreeSet<Integer> treeSet = new TreeSet<>();

        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        ArrayDeque<String> arrayDeque = new ArrayDeque<>();

        HashMap<String, Integer> hashMap = new HashMap<>();
        HashMap<String, Integer> hashMapInit = new HashMap<String, Integer>() {
            {
                put("er", 3);
                put("fg", 4);
            }
        };
        TreeMap<String, Integer> treeMap = new TreeMap<>();
        LinkedHashMap<String, Integer> linkedHashMap = new LinkedHashMap<>();

        //针对list接口
        Collections.reverse(arrayList);
        Collections.swap(linkedList, 5, 6);
        Collections.shuffle(vector);
        Collections.sort(arrayList);
        Collections.replaceAll(arrayList, 98, 99);
        //针对所有
        Collections.min(arrayDeque);
        Collections.max(arrayDeque);
        Collections.frequency(arrayDeque, "fsdv");
        //转换为线程安全
        Collections.synchronizedList(arrayList);
        Collections.synchronizedMap(hashMap);
        Collections.synchronizedSet(hashSet);


    }


}
